<?php

namespace frontend\modules\wxad\models;

use Yii;

/**
 * This is the model class for table "wx_ad".
 *
 * @property string $rec_id
 * @property string $ad_name
 * @property string $ad_images
 * @property string $ad_link *
 * @property string $ad_cat_id
 */
class WxAd extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'wx_ad';
    }

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
//            TimestampBehavior::className(),
            // 名为myBehavior4的行为，也是给出了MyBehavior类的配置数组
            'uuid' => [
                'class' => \common\behavior\uuidBehavior::className(),
                'owner' => $this
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            ['rec_id','default','value'=>$this->getUUID()],
            [['rec_id', 'ad_name', 'ad_link','ad_cat_id'], 'required'],
            [['rec_id'], 'string', 'max' => 40],
            [['ad_name'], 'string', 'max' => 60],
            [['ad_images', 'ad_link'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'rec_id' => Yii::t('app', 'Rec ID'),
            'ad_name' => Yii::t('app', '广告名称'),
            'ad_images' => Yii::t('app', '广告图片'),
            'ad_link' => Yii::t('app', '广告链接'),
            'ad_cat_id' => Yii::t('app', '广告分类'),
        ];
    }

    /**
     * @inheritdoc
     * @return \backend\modules\wxad\models\query\WxAdQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \backend\modules\wxad\models\query\WxAdQuery(get_called_class());
    }
}
